import moment from 'moment'

export const actionColumnsWidth = 250
export const PAGINATION = (obj = {}) => {
    return {
        total: 0,
        position: 'bottom',
        current: 1,
        showSizeChanger: obj.showSizeChanger !== undefined ? obj.showSizeChanger : true,
        pageSizeOptions: obj.pageSizeOptions || ['5', '10', '20', '50'],
        pageSize: obj.pageSize || 10,
        'show-total': function (total) {
            return `共 ${total} 条`
        },
    }
}

const JOB = 4
const DEPARTMENT = 3
const COALLIBRARY = 2
const ENTERPRISE = 1
const COALALARM = 1
const COALNORMAL = 2
export const constant = {
    TOKEN_PREFIX: 'Pzhcis',
    JOB,
    DEPARTMENT,
    COALLIBRARY,
    ENTERPRISE,
    KEEPALIVE: ['home'],
    COALALARM,
    COALNORMAL,
    ALARM_DANGER: 15,
    ALARM_ORANGE: 10,
    ALARM_YELLOW: 5,
    ALARM_NORMAL: 0,
    CODE_CHILD: '01',
    CODE_WHOLE: '00',
}
export const fieldTypeList = [
    {
        type: 'byte',
        value: 1,
    },
    {
        type: 'short',
        value: 2,
    },
    {
        type: 'int',
        value: 3,
    },
    {
        type: 'long',
        value: 4,
    },
    {
        type: 'float',
        value: 5,
    },
    {
        type: 'double',
        value: 6,
    },
    {
        type: 'boolean',
        value: 7,
    },
    {
        type: 'char',
        value: 8,
    },
    {
        type: 'string',
        value: 9,
    },
    {
        type: 'date',
        value: 10,
    },
    {
        type: 'datetime',
        value: 11,
    },
    {
        type: 'json',
        value: 12,
    },
    {
        type: 'text',
        value: 13,
    },
]
export const jobList = [
    {
        name: '一线员工',
        value: 1,
    },
    {
        name: '班组长',
        value: 2,
    },
    {
        name: '车间组长',
        value: 3,
    },
    {
        name: '厂长',
        value: 4,
    },
    {
        name: '安全员',
        value: 5,
    },
    {
        name: '政府人员',
        value: 6,
    },
    {
        name: 'PC端用户',
        value: 7,
    },
    {
        name: '技术人员',
        value: 8,
    },
    {
        name: '安环部',
        value: 9,
    },
]
export const DATEPICKOPTION = (option = {}) => {
    const format = 'YYYY-MM-DD HH:mm'
    const showTime = {
        defaultValue: [moment('00:00', 'HH:mm'), moment('23:59', 'HH:mm')],
        format: 'HH:mm',
    }
    option.format = option.format || format
    option.showTime = option.showTime === false ? false : option.showTime || showTime
    const disabledDate = option.isDisabledDate
        ? {
              disabledDate: current => {
                  return current && current > moment().endOf('day')
              },
          }
        : {}
    return {
        showTime: option.showTime,
        format: option.format,
        ...disabledDate,
        defaultValue: option.defaultValue || [
            moment(moment().subtract(3, 'day'), option.format),
            moment(new Date(), option.format),
        ],
        allowClear: false,
        separator: '-',
    }
}
const xd = {
    codeType: 'adcode',
    codeValue: 510114,
    mapCenter: [104.15921, 30.82314],
    mapZoom: 11,
    sponsor: '新都区应急管理局',
    mapPanby: [-300, -100],
}
const pzh = {
    codeType: 'adcode_cit',
    codeValue: 510400,
    mapZoom: 9,
    mapPanby: [-300, -40],
    mapCenter: [101.716007, 26.580446],
    sponsor: '攀枝花市应急管理局',
}
const qh = {
    codeType: 'adcode_pro',
    codeValue: 630000,
    mapZoom: 6,
    mapCenter: [101.780199, 36.620901],
    sponsor: '青海省应急管理局',
    mapPanby: [-100, -150],
}
const cityConfig = {
    xd,
    pzh,
    qh,
}

const env = {
    city: process.env.VUE_APP_CITY,
    cityTitle: process.env.VUE_APP_CITY_TITLE,
    processBaseSrc: process.env.VUE_APP_BASE_SRC_PROCESS,
    formBaseSrc: process.env.VUE_APP_BASE_SRC_FORM,
    ...cityConfig[process.env.VUE_APP_CITY],
}
export default {
    env,
    constant,
}
// 角色编码(1县（市、区）安委会2市（州）安委会3综评办4综评委成员单位999超级管理员)
export const ROLE_TYPE = {
    1: '县（市、区）',
    2: '市（州）安委会',
    3: '综评办',
    4: '综评委成员单位',
    999: '超级管理员',
}
